package com.dinadi.yidi.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.dinadi.yidi.R;
import com.dinadi.yidi.bean.ReplyListRequestEntity;
import com.dinadi.yidi.utils.FormatCurrentData;
import com.dinadi.yidi.utils.ImageUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * author: JiaYu.He
 * Date: 2017/7/4
 * Time: 19:15
 */

public class CooperationAdapter extends BaseAdapter {

    private Context context;
    ArrayList<HashMap<String, Object>> mList = new ArrayList<HashMap<String, Object>>();


    public CooperationAdapter(Context context, ArrayList<HashMap<String, Object>> mList) {
        this.context = context;
        this.mList = mList;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        CooperationAdapter.ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.adapter_classification_item, null);
            viewHolder = new CooperationAdapter.ViewHolder();
            viewHolder.item_img = (ImageView) convertView.findViewById(R.id.item_img);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (CooperationAdapter.ViewHolder) convertView.getTag();
        }

        String imgUrl = (String) mList.get(position).get("image");
        if (!imgUrl.equals("")) {
            ImageUtils.loadImageView(context, imgUrl, viewHolder.item_img);
        } else {
            ImageUtils.loadImageView(context, R.drawable.me_img_default, viewHolder.item_img);
        }

        return convertView;
    }

    class ViewHolder {
        ImageView item_img;


    }
}
